#include "mypthread.h"
#include <unistd.h>
#include <vector>
#include "BlockQueue.h"
#include "RingQueue.h"

void text(int& x)
{
    while(true)
    {
        printf("hellp, %p\n", &x);
        sleep(1);
    }
} 

pthread_mutex_t mutex;

template<class Fn, class T>
void CreateCom(std::vector<Thread<T>>& id, int num, Fn fn, T& data)
{
    while(num--)
    {
        pthread_mutex_lock(&mutex);
        id.emplace_back(fn, data);
        id.back().Start();
        pthread_mutex_unlock(&mutex);
    }
}

int main()
{
    int i = 0;
    std::vector<Thread<int>> v;
    CreateCom(v, 5, text, i);
    while(1) sleep(1);
    return 0;
}


